﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>运动员注册</title>
    <link href="<%=Url.Content("~/Content/reg.css") %>" rel="stylesheet" type="text/css" />

    <script src="../../Scripts/jquery-1.4.4.js" type="text/javascript"></script>

    <script type="text/javascript" language="javascript">
        function save() {
            var items = "";
            $("#itemlist").find("tr").each(function() {
                items += $(this).find("td:first").find("input").val() + "~" + $(this).find("td:first").text() + ",";
            }
            );
            $("#hiditems").val(items);
            $("#form1").submit();
        }
    </script>

</head>
<body>
    <table width="750" style="background-image: url(../../Content/images/reg/header_bg.png)"
        height="70" cellspacing="0" cellpadding="0" border="0" align="center">
        <tr>
            <td>
                <img src="../../Content/images/reg/logo.png" style="margin-left: 5px;" />
            </td>
        </tr>
    </table>
    <table width="750" height="176" cellspacing="1" cellpadding="0" border="0" align="center">
        <tr>
            <td bgcolor="#ffffff">
                <table width="100%" cellspacing="0" cellpadding="2" border="0">
                    <tr>
                        <td width="180" valign="top" style="border-right: 1px solid rgb(28, 183, 205); background: none repeat scroll 0% 0% rgb(208, 241, 247);
                            border-bottom: 1px solid rgb(28, 183, 205);">
                            <table width="100%" cellspacing="0" cellpadding="2" border="0">
                                <tr>
                                    <td height="33" background="../../Content/images/reg/bmbz.gif">
                                        &nbsp;
                                    </td>
                                </tr>
                            </table>
                            <table width="176px" cellspacing="0" align="right" cellpadding="3" border="0">
                                <tr>
                                    <td bgcolor="#ffffff">
                                        <br />
                                    </td>
                                </tr>
                                <tr>
                                    <td bgcolor="#ffffff">
                                        ①阅读报名须知<br />
                                    </td>
                                </tr>
                                <tr>
                                    <td bgcolor="#ffffff">
                                        ②填写个人信息<br />
                                    </td>
                                </tr>
                                <tr>
                                    <td bgcolor="#ffffff">
                                        ③选择报名项目<br />
                                    </td>
                                </tr>
                                <tr>
                                    <td bgcolor="#ffffff">
                                        ④确认报名信息<br />
                                    </td>
                                </tr>
                                <tr>
                                    <td bgcolor="#ffffff">
                                        ⑤完成报名<br />
                                    </td>
                                </tr>
                            </table>
                        </td>
                        <td valign="top" bgcolor="#fcfcfc">
                            <%using (Html.BeginForm("RegItem", "Reg", FormMethod.Post, new { id = "form1" }))
                              {%>
                            <table width="99%" cellspacing="1" cellpadding="1" border="1" bgcolor="#f7f7f7" align="center"
                                class="text" bordercolordark="#Ffffff" bordercolorlight="#cccccc">
                                <tr bgcolor="#ffffff">
                                    <td height="30" bgcolor="#e8e8e8">
                                        <div align="center">
                                            <font size="2" color="#000000"><strong><font color="#ff3300">第3步</font></strong> <strong>
                                                选择报名项目</strong></font></div>
                                    </td>
                                </tr>
                                <tr bgcolor="#ffffff">
                                    <td valign="top" bgcolor="#ffffff" background="../image/water_bg.gif">
                                        <table cellspacing="1" cellpadding="5" border="0" bgcolor="#efefef" align="center"
                                            width="100%">
                                            <tr bgcolor="#f5f7f8">
                                                <td align="right">
                                                    姓&nbsp;&nbsp;&nbsp;&nbsp;名：
                                                </td>
                                                <td>
                                                    <label>
                                                        <%=ViewData["playername"]%><input type="hidden" name="sex" id="sex" value="<%=ViewData["sex"] %>" />
                                                    </label>
                                                    <font color="red">*</font>
                                                </td>
                                            </tr>
                                            <tr bgcolor="#f5f7f8">
                                                <td align="right">
                                                    项目类型：
                                                </td>
                                                <td>
                                                    <select id="sltitemtype" name="sltitemtype" style="width: 150px">
                                                        <option value="">请选择...</option>
                                                        <option value="1">竞赛</option>
                                                        <option value="2">田赛</option>
                                                    </select>
                                                    <font color="red">*</font>
                                                </td>
                                            </tr>
                                            <tr bgcolor="#f5f7f8">
                                                <td align="right">
                                                    项&nbsp;&nbsp;&nbsp;&nbsp;目：
                                                </td>
                                                <td>
                                                    <select id="sltitem" name="sltitem" style="width: 150px" disabled="disabled">
                                                    </select>
                                                    <font color="red">*</font>
                                                </td>
                                            </tr>
                                            <tr bgcolor="#f5f7f8">
                                                <td align="center" colspan="2">
                                                    <input type="button" value="添   加" onclick="additem()" />
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <hr size="1">
                                <tr>
                                    <td colspan="2" bgcolor="#e8e8e8">
                                        <table cellspacing="1" cellpadding="5" border="0" bgcolor="#efefef" align="center"
                                            width="100%">
                                            <tr>
                                                <td align="center">
                                                    填报项目
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr bgcolor="#ffffff">
                                    <td valign="top" bgcolor="#ffffff" background="../image/water_bg.gif">
                                        <table id="itemlist" cellspacing="1" cellpadding="5" border="0" bgcolor="#efefef"
                                            align="center" width="100%">
                                            <%Dictionary<int, string> dic = (Dictionary<int, string>)ViewData["items"];
                                              if (dic != null)
                                              {
                                                  foreach (int key in dic.Keys)
                                                  {%>
                                            <tr bgcolor="#f5f7f8">
                                                <td align="center">
                                                    <%= dic[key]%><input type="hidden" value="<%=key %>" />
                                                </td>
                                                <td align="center">
                                                    <input type="button" value="删除" onclick="delitem(this)" />
                                                </td>
                                            </tr>
                                            <%}
                                              } %>
                                        </table>
                                    </td>
                                </tr>
                                <tr bgcolor="#f5f7f8">
                                    <td align="center" colspan="2">
                                        <input type="button" value="&lt;&lt;上一步" onclick="location.href='../Reg/RegPlayer'"
                                            class="btn01" name="Submit1" />
                                        <input type="button" value="下一步&gt;&gt;" onclick="save();" />
                                        <input type="hidden" id="hiditems" name="hiditems" />
                                    </td>
                                </tr>
                            </table>
                            <%} %>
                        </td>
                    </tr>
                </table>
                <table width="750" cellspacing="0" cellpadding="0" border="0" align="center">
                    <tr>
                        <td height="30" align="center">
                            安徽新闻出版职业技术学院——运动会管理平台
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>

    <script type="text/javascript" language="javascript">
        function additem() {
            var flag = "0";
            var count = 0;
            $("#itemlist").find("tr").each(function() {
                var txt = $.trim($(this).find("td:first").text());
                if (txt == $("#sltitem").find("option:selected").text()) {
                    flag = "1";
                    return false;
                }
                var index = txt.indexOf("X");
                if (index == -1)
                    count++;
            });
            if (flag == "1") {
                alert("该项目已经添加！");
                return;
            }
            if ($("#sltitem").find("option:selected").text().indexOf("X") == -1) {
                if (count == 3) {
                    alert("个人项目只能填报三项！");
                    return;
                }
            }
            str = "<tr bgcolor=\"#f5f7f8\"><td align=\"center\">" + $("#sltitem").find("option:selected").text() + "<input type=\"hidden\" value=\"" + $("#sltitem").val() + "\"></input></td><td align=\"center\"><input type=\"button\" value=\"删除\" onclick=\"delitem(this)\" /></td></tr>";
            $("#itemlist").append(str);
        }
        function delitem(obj) {
            $(obj).parent().parent().remove();
        }
        $(document).ready(function() {
            $('#sltitemtype').change(function() {
                $.ajaxSetup({ cache: false });
                var selectedItem = $(this).val();
                if (selectedItem == "" || selectedItem == 0) {
                    $("#sltitem").html("");
                    $("#sltitem").attr('disabled', "disabled");
                } else {
                    var sltitemtype = $("#sltitemtype > option:selected").attr("value");
                    var sexvalue = $("#sex").val();
                    $.ajax({
                        type: "post",
                        dataType: "json",
                        url: '<%=Url.Action("GetItemInfo")%>',
                        data: { "itemtype": sltitemtype, "sex": sexvalue },
                        success: function(data) {
                            var items = "";
                            if (data == null)
                                return;
                            $.each(data, function(i, data) {
                                items += "<option value='" + data.id + "'>" + data.name + "</option>";
                            });
                            $("#sltitem").html(items);
                            $("#sltitem").removeAttr('disabled');
                        }
                    });
                }
            });
        });
    </script>

</body>
</html>
